unit U_fm_turma;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, cxGraphics, cxControls, cxLookAndFeels,
  cxLookAndFeelPainters, cxContainer, cxEdit, dxSkinsCore, dxSkinBlack,
  dxSkinBlue, dxSkinBlueprint, dxSkinCaramel, dxSkinCoffee, dxSkinDarkRoom,
  dxSkinDarkSide, dxSkinDevExpressDarkStyle, dxSkinDevExpressStyle, dxSkinFoggy,
  dxSkinGlassOceans, dxSkinHighContrast, dxSkiniMaginary, dxSkinLilian,
  dxSkinLiquidSky, dxSkinLondonLiquidSky, dxSkinMcSkin, dxSkinMoneyTwins,
  dxSkinOffice2007Black, dxSkinOffice2007Blue, dxSkinOffice2007Green,
  dxSkinOffice2007Pink, dxSkinOffice2007Silver, dxSkinOffice2010Black,
  dxSkinOffice2010Blue, dxSkinOffice2010Silver, dxSkinOffice2013White,
  dxSkinPumpkin, dxSkinSeven, dxSkinSevenClassic, dxSkinSharp, dxSkinSharpPlus,
  dxSkinSilver, dxSkinSpringTime, dxSkinStardust, dxSkinSummer2008,
  dxSkinTheAsphaltWorld, dxSkinsDefaultPainters, dxSkinValentine, dxSkinVS2010,
  dxSkinWhiteprint, dxSkinXmas2008Blue, Vcl.ComCtrls, cxLabel, Vcl.ToolWin,
  Vcl.ExtCtrls, Vcl.ImgList, cxListView, Vcl.StdCtrls, Vcl.DBCtrls, Vcl.Grids,
  Vcl.DBGrids, Vcl.Mask, cxStyles, cxVGrid, cxInplaceContainer, cxDBVGrid,
  dxSkinscxPCPainter, cxCustomData, cxFilter, cxData, cxDataStorage,
  cxNavigator, Data.DB, cxDBData, cxGridLevel, cxClasses, cxGridCustomView,
  cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxGrid, Vcl.Menus,
  cxButtons, cxTextEdit, cxMaskEdit, cxDropDownEdit, cxCalendar, cxDBEdit,
  cxPCdxBarPopupMenu, cxButtonEdit, cxPC;

type
  Tfm_turma = class(TForm)
    cxImageList1: TcxImageList;
    Panel1: TPanel;
    ToolBar1: TToolBar;
    cxLabel1: TcxLabel;
    ToolButton4: TToolButton;
    ToolButton1: TToolButton;
    ToolButton2: TToolButton;
    ToolButton3: TToolButton;
    Panel5: TPanel;
    ToolBar2: TToolBar;
    ToolButton9: TToolButton;
    ToolButton5: TToolButton;
    ToolButton6: TToolButton;
    ToolButton7: TToolButton;
    ToolButton8: TToolButton;
    ToolButton10: TToolButton;
    ToolButton11: TToolButton;
    ToolButton14: TToolButton;
    ToolButton15: TToolButton;
    ToolButton16: TToolButton;
    ToolButton17: TToolButton;
    ToolButton18: TToolButton;
    ImageList1: TImageList;
    Panel2: TPanel;
    ImageList2: TImageList;
    btn1: TToolButton;
    btn2: TToolButton;
    cxDBComboBox1: TcxDBComboBox;
    cxDBTextEdit11: TcxDBTextEdit;
    lbl19: TLabel;
    lbl1: TLabel;
    lbl2: TLabel;
    cxDBTextEdit1: TcxDBTextEdit;
    lbl3: TLabel;
    cxDBComboBox2: TcxDBComboBox;
    PagCtrl01_DadosBasicos: TcxPageControl;
    PagSheet01_DadosBasicos: TcxTabSheet;
    cxGrid2: TcxGrid;
    cxGridDBTableView1: TcxGridDBTableView;
    cxGridDBColumn1: TcxGridDBColumn;
    cxGridDBColumn2: TcxGridDBColumn;
    cxGridLevel1: TcxGridLevel;
    pnl1: TPanel;
    tlb1: TToolBar;
    btn3: TToolButton;
    btn4: TToolButton;
    lbl4: TLabel;
    Edt_CodAluno: TcxDBButtonEdit;
    Edt_NomeAluno: TcxDBTextEdit;
    lbl5: TLabel;
    cxStyleRepository1: TcxStyleRepository;
    cxStyle1: TcxStyle;
    cxStyle2: TcxStyle;
    procedure ToolButton3Click(Sender: TObject);
    procedure btn1Click(Sender: TObject);
    procedure ToolButton9Click(Sender: TObject);
    procedure ToolButton11Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure ToolButton8Click(Sender: TObject);
    procedure btn3Click(Sender: TObject);
    procedure PagCtrl01_DadosBasicosDrawTab(AControl: TcxCustomTabControl;
      ATab: TcxTab; var DefaultDraw: Boolean);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  fm_turma: Tfm_turma;

implementation

{$R *.dfm}

uses U_dm_principal, UMyLib;

procedure Tfm_turma.btn1Click(Sender: TObject);
begin
Close;
end;

procedure Tfm_turma.FormShow(Sender: TObject);
begin
dm_principal.cds_turma.Open;
dm_principal.cds_aluno.Open;
end;

procedure Tfm_turma.PagCtrl01_DadosBasicosDrawTab(AControl: TcxCustomTabControl;
  ATab: TcxTab; var DefaultDraw: Boolean);
begin
TMyLib.MyPagCtrlDrawTab(Acontrol,Atab,DefaultDraw);
end;

procedure Tfm_turma.ToolButton11Click(Sender: TObject);
begin
dm_principal.cds_turma.Post;
dm_principal.cds_turma.ApplyUpdates(0);
end;

procedure Tfm_turma.btn3Click(Sender: TObject);
begin
dm_principal.cds_turmaTUR_FKALU_ID.Value:=dm_principal.cds_alunoALU_ID.Value;
dm_principal.cds_turmaTUR_NOMEALUNO.Value:=dm_principal.cds_alunoALU_NOME.Value;
end;

procedure Tfm_turma.ToolButton3Click(Sender: TObject);
begin
Close;
end;

procedure Tfm_turma.ToolButton8Click(Sender: TObject);
begin
dm_principal.cds_turma.Cancel;
end;

procedure Tfm_turma.ToolButton9Click(Sender: TObject);
begin
dm_principal.cds_turma.Insert;
dm_principal.sq_generators.Close;
dm_principal.sq_generators.SQL.Text:='select gen_id(GEN_TURMAS_ID,1)as id from Rdb$database';
dm_principal.sq_generators.Open;
dm_principal.cds_turmaTUR_ID.Value:=dm_principal.sq_generators.FieldByName('id').AsInteger;

end;

end.
